from selenium.webdriver.common.by import By


class SendMassagePage:
    def __init__(self, driver):
        self.driver = driver

    url = "http://192.168.1.9/crm"
    username_locator = (By.NAME, 'name')
    password_locator = (By.NAME, 'password')
    btn_login_locator = (By.NAME, 'submit')
    btn_gengduo_locator = (By.CSS_SELECTOR,
                           'body > div.navbar.navbar-inverse.navbar-fixed-top > div > div > div.nav-collapse.collapse > ul:nth-child(1) > li.dropdown > a')
    btn_yingxiao_locator = (By.CSS_SELECTOR,
                            'body > div.navbar.navbar-inverse.navbar-fixed-top > div > div > div.nav-collapse.collapse > ul:nth-child(1) > li.dropdown.open > ul > li:nth-child(3) > a')
    tel_locator = (By.NAME, 'phoneNum')
    neirong_locator = (By.ID, 'smsContent')
    fasong_btn_locator = (By.CSS_SELECTOR,
                          'body > div.container > div.row > div:nth-child(2) > form > div > div:nth-child(2) > div:nth-child(3) > p:nth-child(3) > input.btn.btn-primary')

    def input_username(self, username):
        self.driver.find_element(*self.username_locator).send_keys(username)

    def input_password(self, password):
        self.driver.find_element(*self.password_locator).send_keys(password)

    def click_btn_login(self):
        self.driver.find_element(*self.btn_login_locator).click()

    def open(self):
        self.driver.get(self.url)

    def click_btn_gengduo(self):
        self.driver.find_element(*self.btn_gengduo_locator).click()

    def click_btn_yingxiao(self):
        self.driver.find_element(*self.btn_yingxiao_locator).click()

    def input_tel(self):
        self.driver.find_element(*self.tel_locator).send_keys(tel)

    def input_neirong(self):
        self.driver.find_element(*self.neirong_locator).send_keys(neirong)

    def click_btn_fasong(self):
        self.driver.find_element(*self.fasong_btn_locator).click()